//
//  ProductDetailViewController.m
//  PagingDemo
//
//  Created by Liu jinyong on 15/8/6.
//  Copyright (c) 2015年 Baidu 91. All rights reserved.
//

#import "ProductDetailViewController.h"
#import "SVPullToRefresh.h"

@interface ProductDetailViewController ()<UIWebViewDelegate>

@property(nonatomic, strong) UIWebView *webView;
@property(nonatomic, copy) NSString *productId;

@end

@implementation ProductDetailViewController

- (id) initWithProductId:(NSString *)productId {
    if (self = [super init]) {
        self.productId = productId;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
//    _scrollView.contentSize = CGSizeMake(0, 700);
    [self.scrollView addSubview:self.webView];
}

- (UIWebView *)webView {
    if (!_webView) {
        _webView = [[UIWebView alloc] initWithFrame:self.scrollView.bounds];
        _webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        NSString *url = [NSString stringWithFormat:@"%@/products/%@%@",DOMAIN_ADDRESS,self.productId, @"/description"];
        [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
        
        _webView.delegate = self;
    }
    return _webView;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    _scrollView.contentSize = self.webView.scrollView.contentSize;
}

@end
